
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ include file="/include/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="<%=request.getContextPath()%>/resources/servicePro/jquery.uploadify.min.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/servicePro/uploadify.css">
</head>
<body>
<div class="container">
    <div class="main_top">
        <div class="main_right fr span10">
            <div class="box pl5">
                <div class="box_border">
                    <div class="box_top">
                        <div class="box_top_l fl">
                            <b class="pl15">数据</b>
                        </div>
                    </div>

                    <div class="box_center">
                        <div id="table" class=" fl mt10">
                            <div class="box span10 oh">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0"
                                       class="list_table">
                                    <tr>
                                        <th width="1.5%">序号</th>
                                        <th width="2%">缩略图</th>
                                        <th width="3%">作品发布人</th>
                                        <th width="4%">学校</th>
                                        <th width="2%" data-sort_v="${sort_v}">点赞量</th>
                                        <th width="5%" data-sort_v="${sort_v}">作品发布时间</th>
                                        <%--<th width="5%">活动发布人</th>--%>
                                        <th width="5%">获奖名称</th>
                                        <th width="3%">积分</th>
                                        <th width="6%">操作</th>
                                    </tr>
                                        <c:if test="${fn:length(honorsBeans)==0}"><tr class="tr"><td align="center" colspan="9">暂无数据</td> </tr></c:if>
                                        <c:if test="${fn:length(honorsBeans)>0}">
                                            <c:forEach items="${honorsBeans}" var="honors" varStatus="abc">
                                                <tr class="tr">
                                                    <td align="center">
                                                        <c:out value="${(PageBean.currentpage-1)*PageBean.pagesize+abc.index + 1}" />
                                                       <%-- <input type="radio" name="cb-fuck" data-id="${honors.workId}${abc.index + 1}" data-workid="${honors.workId}">--%>
                                                    </td>
                                                    <td align="center">
                                                        <a href="<%=imgPath %>${honors.pic1}" data-lightbox="image-1" id="showImg" > <IMG alt="活动缩略图" width="50" height="50" src="<%=imgPath %>${honors.pic1}"/></a>
                                                    </td>
                                                    <td align="center"><c:out value="${honors.userName}" /></td>
                                                    <td align="center"><c:out value="${honors.schoolName}" /></td>
                                                    <td align="center"><c:out value="${honors.goodsNumber}" /></td>
                                                    <td align="center"><c:out value="${honors.createTime}" /></td>
                                                    <%--<td align="center"><c:out value="${honors.ployUserName}" /></td>--%>
                                                    <td align="center">
                                                        <span id="span-honorsname-${honors.workId}${abc.index + 1}">${honors.honorsName}</span>
                                                        <input id="honors-${honors.workId}${abc.index + 1}" value="${honors.honorsName}"  class="input-text lh30 hide_input" style="width:150px" maxlength="20">
                                                    </td>
                                                    <td align="center">
                                                        <span id="span-score-${honors.workId}${abc.index + 1}">${honors.score}</span>
                                                        <input id="score-${honors.workId}${abc.index + 1}" value="${honors.score}" class="input-text lh30 hide_input" style="width:50px" maxlength="3"></td>
                                                    <td align="center">
                                                        <input type="button" name="fuck_show_honors" id="button0-${honors.workId}${abc.index + 1}" data-id="${honors.workId}${abc.index + 1}" data-workid="${honors.workId}" value="评奖" class="new_btn new_btn_add">
                                                        <input type="button" id="button-${honors.workId}${abc.index + 1}" onclick="submitHonors('${honors.workId}${abc.index + 1}','${honors.userId}')"  data-workid="${honors.workId}" data-ployid="${honors.ployId}" class="new_btn new_btn_submit hide_input" value="确定">
                                                        <input type="button" class="new_btn new_btn_up" onclick="window.open('<%=request.getContextPath()%>/back/student/querypic1.do?name=8&schoolId=${honors.workId}','querypic','left=200,top=150,width=900,height=500,titlebar=no,location=no')" value="查看图片">
                                                    </td>
                                                </tr>
                                            </c:forEach>
                                        </c:if>
                                </table>
                                <div class="fr fontblack mt25 mb20 mr20">
                                    每页条数：<a href="<%=request.getContextPath()%>/back/actBack/getHonors.do?id=${id}&sort=${sort}&sort_v=${sort_v}&pz=5"
                                            class="${pageSize == 5 ? 'fontpink' : ''}">5</a> | <a
                                        href="<%=request.getContextPath()%>/back/actBack/getHonors.do?id=${id}&sort=${sort}&sort_v=${sort_v}&pz=10"
                                        class="${pageSize == 10 ? 'fontpink' : ''}">10</a> | <a
                                        href="<%=request.getContextPath()%>/back/actBack/getHonors.do?id=${id}&sort=${sort}&sort_v=${sort_v}&pz=20"
                                        class="${pageSize == 20 ? 'fontpink' : ''}">20</a>
                                </div>
                                <div class="fr fontblack mt5 mb20 mr20">
                                    <jsp:include page="../template/commonPagination.jsp">
                                        <jsp:param name="url" value="getHonors.do?id=${id}&sort=${sort}&sort_v=${sort_v}&"></jsp:param>
                                    </jsp:include>
                                </div>
                            </div>
                        </div>
                    </div>
                 </div>
             </div>
        </div>
     </div>
</div>
<script type="application/javascript">
    $(function () {
        init();
    });

    function init() {
        $('.hide_input').hide();
        $("#table tr:eq(0)").on("click", "th:eq(4)", function(e) {

            var sort_v = $(this).attr("data-sort_v");
            if(sort_v == 'DESC'){
                sort_v='ASC';
            }else {
                sort_v='DESC';
            }
            $(this).attr("data-sort",sort_v);
            window.location= "<%=request.getContextPath()%>/back/actBack/getHonors.do?id=${id}&sort=goodsNumber&sort_v="+sort_v;
        });
        $("#table tr:eq(0)").on("click", "th:eq(5)", function(e) {

            var sort_v = $(this).attr("data-sort_v");
            if(sort_v == 'DESC'){
                sort_v='ASC';
            }else {
                sort_v='DESC';
            }
            $(this).attr("data-sort_v",sort_v);
            window.location= "<%=request.getContextPath()%>/back/actBack/getHonors.do?id=${id}&sort=w.create_time&sort_v="+sort_v;
        });
        $("#table tr").on("click", "td:eq(8) input[name=fuck_show_honors]:eq(0)", function(e) {
            var id = $(this).attr('data-id');

            $('#span-honorsname-'+id).toggle();
            $('#span-score-'+id).toggle();
            $('#honors-'+id).toggle();
            $('#score-'+id).toggle();
            $('#button-'+id).toggle();
            $('#button0-'+id).toggle();
        });
    }

    function submitHonors(id,userId) {

        var data = $('#button-'+id);
        var ploy_id = data.attr('data-ployid');
        var work_id = data.attr('data-workid');
        var honorsname = $('#honors-'+id).val();
        var score = $('#score-'+id).val();
        $.ajax( {
            type : "POST",
            url : "<%=request.getContextPath()%>/back/actBack/dohonors.do",
            data:{"ployId":ploy_id,"workId":work_id,"honorsName":honorsname,"score":score,"userId":userId},
            dataType: "json",
            async : false,
            success : function(data) {
                if(data.code=="0000"){
                    alert("操作成功!");
                    if(score < 0){
                        honorsname = '';
                        score = 0;
                    }
                    $('#span-honorsname-'+id).text(honorsname);
                    $('#span-score-'+id).text(score);
                    $('#span-honorsname-'+id).toggle();
                    $('#span-score-'+id).toggle();
                    $('#honors-'+id).toggle();
                    $('#score-'+id).toggle();
                    $('#button-'+id).toggle();
                    $('#button0-'+id).toggle();
//                    location.reload();
                }else{
                    alert(data.code+data.codeMsg);
                }
            }
        });


    }
</script>
</body>
</html>
